<%@ page language="java" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<head>
    <jsp:include page="../common/common.jsp"/>
    <link href="${path}/assets/css/plugins.css" rel="stylesheet" type="text/css"/>
</head>
<body class="page-header-fixed">
<jsp:include page="../common/header.jsp"/>
<div class="clearfix">
</div>
<div class="page-container">
<div class="page-sidebar-wrapper">
    <jsp:include page="../common/menu.jsp"/>
</div>
<div class="page-content-wrapper">
<div class="page-content">
<div class="row">
<div class="col-md-12">
<form class="form-horizontal form-row-seperated">
<div class="portlet box purple">
<div class="portlet-title">
    <div class="caption">
        <i class="fa fa-shopping-cart"></i>会员信息
    </div>
    <div class="actions btn-set">
        <a href="javascript:history.go(-1);" class="btn default"><i class="fa fa-angle-left"></i> 返回</a>
        <a href="javascript:location.reload();" class="btn green"><i class="fa fa-reply"></i> 重置</a>
        <button type="button" id="btnSave" class="btn blue"><i class="fa fa-check"></i> 保存</button>
    </div>
</div>
<div class="portlet-body">
<div class="tabbable">
<div class="tab-content no-space">
<div class="tab-pane active" id="tab_general">
<div class="form-body">
<div class="form-group">
    <label class="col-md-2 control-label">用户名:
        <span class="required">*</span>
    </label>
    <div class="col-md-8">
        <input type="text" name="userName" class="form-control" datatype="*"
               ignore="ignore" value="${data.userName}"
               <c:if test="${data.userName!=null}">readonly="readonly"</c:if>/>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">用户状态:</label>
    <div class="col-md-3">
        <select name="status" class="form-control">
            <option value="0">活动</option>
            <option value="1" <c:if test="${data.status=='1'}">selected="selected"</c:if>>冻结</option>
        </select>
    </div>
    <label class="col-md-2 control-label">认证状态:</label>
    <div class="col-md-3">
        <select name="approve" class="form-control">
            <option value="0" <c:if test="${data.approve=='0'}">selected="selected"</c:if>>未认证</option>
            <option value="1" <c:if test="${data.approve=='1'}">selected="selected"</c:if>>已认证</option>
            <option value="2" <c:if test="${data.approve=='2'}">selected="selected"</c:if>>审核不通过</option>
            <option value="3" <c:if test="${data.approve=='3'}">selected="selected"</c:if>>等待认证</option>
        </select>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">积分:</label>
    <div class="col-md-3">
        <input type="text" name="score" class="form-control" datatype="n|/^-?\d+\.\d+$/" ignore="ignore"
               value="${data.score}"/>
    </div>
    <label class="col-md-2 control-label">S币:</label>
    <div class="col-md-3">
        <input type="text" name="money" class="form-control" datatype="n|/^-?\d+\.\d+$/" ignore="ignore"
               value="${data.money}"/>
    </div>
</div>
<!-- 企业信息 -->
<div class="form-group">
    <label class="col-md-2 control-label">企业名称:
        <span class="required">*</span>
    </label>
    <div class="col-md-8">
        <input type="hidden" name="company.id" class="form-control" value="${data.company.id}"/>
        <input type="text" name="company.companyName" class="form-control" datatype="*1-20"
               value="${data.company.companyName}"/>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">企业电话:
        <span class="required">*</span>
    </label>
    <div class="col-md-3">
        <input type="text" name="mobile" class="form-control" value="${data.mobile}"
               datatype="/^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$/"
               errormsg="请填写正确座机号码(区号与电话号码之间用“-”隔开)" nullmsg="请填写座机号码"/>
    </div>
    <label class="col-md-2 control-label">企业邮箱:
        <span class="required">*</span>
    </label>
    <div class="col-md-3">
        <input type="text" name="company.email" class="form-control" datatype="e"
               value="${data.company.email}"/>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">企业地址:
        <span class="required">*</span>
    </label>
    <div class="col-md-3">
        <input type="text" name="company.address" class="form-control" datatype="*"
               value="${data.company.address}"/>
    </div>
    <label class="col-md-2 control-label">邮编:
        <span class="required">*</span>
    </label>
    <div class="col-md-3">
        <input type="text" name="company.zipcode" class="form-control" datatype="p"
               value="${data.company.zipcode}"/>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">营业执照注册号:
        <span class="required">*</span>
    </label>

    <div class="col-md-3">
        <input type="text" name="company.businessNum" class="form-control" datatype="*"
               value="${data.company.businessNum}"/>
    </div>
    <label class="col-md-2 control-label">营业执照住所地:
        <span class="required">*</span>
    </label>

    <div class="col-md-3">
        <input type="text" name="company.businessAddress" class="form-control" datatype="*"
               value="${data.company.businessAddress}"/>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">营业期限:
        <span class="required">*</span>
    </label>

    <div class="col-md-3">
        <input type="text" name="company.deadline" class="form-control" datatype="*"
               value="${data.company.deadline}"/>
    </div>
    <label class="col-md-2 control-label">成立日期:
        <span class="required">*</span>
    </label>

    <div class="col-md-3">
        <input type="text" name="company.buildDate" class="form-control" datatype="*"
               value="${data.company.buildDate}" readonly="readonly"
               onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">经营范围:
        <span class="required">*</span>
    </label>

    <div class="col-md-3">
        <input type="text" name="company.spectrum" class="form-control" datatype="*"
               value="${data.company.spectrum}"/>
    </div>
    <label class="col-md-2 control-label">主营产品:
        <span class="required">*</span>
    </label>

    <div class="col-md-3">
        <input type="text" name="company.mainProduct" class="form-control" datatype="*"
               value="${data.company.mainProduct}"/>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">备注:</label>

    <div class="col-md-3">
        <input type="text" name="company.remark" class="form-control" value="${data.company.remark}"/>
    </div>
</div>

<div class="form-group" id="pic">
    <label class="col-md-2 control-label">企业LOGO:<span class="required">*</span></label>

    <div class="col-md-8">
        <div class="fileinput fileinput-new" data-provides="fileinput">
            <div class="fileinput-new thumbnail" style="width: 300px; height: 150px;">
                <a data-toggle="modal" href="#logoImg">
                    <img src="${data.company.logoImg}"/>
                </a>
            </div>
            <div class="fileinput-preview fileinput-exists thumbnail"
                 style="max-width: 300px; max-height: 150px;">
            </div>
            <div>
														<span class="btn default btn-file">
															<span class="fileinput-new">
																 Select image
															</span>
															<span class="fileinput-exists">
																 Change
															</span>
															<input type="file" id="file" name="file"/>
															
														</span>
                <a href="#" class="btn default fileinput-exists" data-dismiss="fileinput">
                    Remove
                </a>
            </div>
        </div>
    </div>
</div>

<div class="form-group" id="pic2">
    <label class="col-md-2 control-label">营业执照副本扫描件:<span class="required">*</span></label>

    <div class="col-md-8">
        <div class="fileinput fileinput-new" data-provides="fileinput">
            <div class="fileinput-new thumbnail" style="width: 300px; height: 150px;">
                <a data-toggle="modal" href="#panelPic">
                    <img src="${data.company.scanFile}"/>
                </a>
            </div>
            <div class="fileinput-preview fileinput-exists thumbnail"
                 style="max-width: 300px; max-height: 150px;">
            </div>
            <div>
														<span class="btn default btn-file">
															<span class="fileinput-new">
																 Select image
															</span>
															<span class="fileinput-exists">
																 Change
															</span>
															<input type="file" id="file1" name="file1"/>
															
														</span>
                <a href="#" class="btn default fileinput-exists" data-dismiss="fileinput">
                    Remove
                </a>
            </div>
        </div>
    </div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade bs-modal-sm" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-body">
                <img src="${data.company.logoImg}"/>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<div class="modal fade bs-modal-sm" id="panelPic" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-body">
                <img src="${data.company.scanFile}"/>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
</div>

<div class="portlet-title">
    <div class="actions btn-set">
        <a href="javascript:history.go(-1);" class="btn default"><i class="fa fa-angle-left"></i> 返回</a>
        <a href="javascript:location.reload();" class="btn green"><i class="fa fa-reply"></i> 重置</a>
        <button type="button" id="btnSave" class="btn blue"><i class="fa fa-check"></i> 保存</button>
    </div>
</div>
</div>
<input type="hidden" name="id" value="${data.id}">
<input type="hidden" name="userType" value="${data.userType}">

<input type="hidden" name="company.scanFile" id="scanFile" value="${data.company.scanFile}">
<input type="hidden" name="company.logoImg" id="logoImg" value="${data.company.logoImg}">


</form>
</div>
</div>
</div>
</div>
</div>
<jsp:include page="../common/footer.jsp"/>
<script type="text/javascript" src="${path}/assets/plugins/calendar/WdatePicker.js"></script>
<script type="text/javascript" src="${path}/assets/scripts/biz/jsAddress.js"></script>

<script type="text/javascript" src="${path}/assets/plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery-inputmask/jquery.inputmask.bundle.min.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery.input-ip-address-control-1.0.min.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery.pwstrength.bootstrap/src/pwstrength.js"></script>
<script type="text/javascript" src="${path}/assets/scripts/biz/ajaxfileupload.js"></script>

<script>
    var form;
    jQuery(document).ready(function () {
        form = $("form").Validform({
            tiptype: 3,
            postonce: true,
            showAllError: true,
            callback: function (data) {
                if (data && data.statusCode === 200) {
                    //if(confirm("保存成功，是否跳转到会员管理页面？"))
                    history.go(-1);
                } else {
                    alert("保存失败！");
                }
            }
        });

        $("button[id='btnSave']").click(function () {
            ajaxFileUpload();
        });

    });

    function save() {
        form.ajaxPost(false, true, _path + "/member/save");
    }
    function ajaxFileUpload() {
        if(!$("#logoImg").val() && !$("#file").val()) {
            alert("请上传企业LOGO！");
            return;
        }
        if(!$("#scanFile").val() && !$("#file1").val()) {
            alert("请上传营业执照副本扫描件！");
            return;
        }
        $("#loading").ajaxStart(function () {
            $(this).show();
        }).ajaxComplete(function () {
            $(this).hide();
        });
        if($("#file").val()) {
            $.ajaxFileUpload({
                url: '${path}/conf/upload',
                secureuri: false,
                fileElementId: 'file',
                dataType: 'json',
                success: function (data, status) {
                    switch (data.statusCode) {
                        case 200 :
                            $("#logoImg").val(data.uri);
                            break;
                        case 500 :
                            alert(data.info);
                            break;
                    }
                }
            });
        }
        if($("#file").val()) {
            $.ajaxFileUpload({
                url: '${path}/conf/upload',
                secureuri: false,
                fileElementId: 'file1',
                dataType: 'json',
                success: function (data, status) {
                    switch (data.statusCode) {
                        case 200 :
                            $("#scanFile").val(data.uri);
                            break;
                        case 500 :
                            alert(data.info);
                            break;
                    }
                }
            });
        }
        save();
        return false;
    }
</script>
</body>
<!-- END BODY -->
</html>